package com.group2.bankonline.service.impl;

import com.group2.bankonline.pojo.Personinfo;
import com.group2.bankonline.mapper.PersoninfoMapper;
import com.group2.bankonline.service.IPersoninfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author syf
 * @since 2024-07-11
 */
@Service
public class PersoninfoServiceImpl extends ServiceImpl<PersoninfoMapper, Personinfo> implements IPersoninfoService {

    @Resource
    private RedisTemplate redisTemplate;

    @Override
    public Personinfo getByTelAndPwd(String tel, String pwd) {
        return baseMapper.selectByTelAndPwd(tel,pwd);
    }

    public Personinfo getByTel(String tel) {
        return baseMapper.selectByTel(tel);
    }

    @Override
    public Personinfo getByRealName(String realname) {
        return  baseMapper.selectByRealname(realname);
    }

    @Override
    public int updateinfo(Personinfo personinfo) {
        int updateinfo = baseMapper.updateinfo(personinfo);
        return updateinfo;
    }

    @Override
    public String selectTelById(int id) {
        return baseMapper.selectTelById(id);
    }

    @Override
    public void logout(String token) {
        redisTemplate.delete(token);
    }
}
